<?php
class Main extends CI_controller{

    public function index(){

        $this->load->model('Main_mod');

        $page = $this->uri->segment(4,1);
        $limit = 2;
        $start = ($page-1)*$limit;

        $this->session->unset_userdata('islogin');
        $article = $this->Main_mod->getArticle('',$start,$limit);
        // dump($article);

        // 加载分页类

        // $this->load->library('test');

        // $this->test->hello();

        $count = $this->Main_mod->getCount('');
        // if($_SESSION){
        // 	dump($_SESSION);
        // }


        /*$this->load->library('pagination');
        // 配置分页所在的控制器下的方法的地址
        $config['base_url'] = site_url('main/index');
        // 总记录数
        $config['total_rows'] = $count;
        // 每页显示的记录数
        $config['per_page'] = $limit;
        // 使用页面数作为分页的参数
        $config['use_page_numbers'] = TRUE;

        $this->pagination->initialize($config);

        $page_link = $this->pagination->create_links();*/
        $this->pagelink->controller='main';
        $this->pagelink->funcName='index';
        $this->pagelink->limit=$limit;
        $this->pagelink->count=$count;
        //$this->Pagelink->kind='main';
        $data['pagetitle'] = "首页";
        $data['article'] = $article;
        $data['page_link'] = $this->pagelink->createLink();
        $this->load->view("main", $data);



/*        $this->load->model('Article_mod');
        $data['article'] = $this->Article_mod->article();
        $this->load->view('main',$data);*/
    }

    public function loginOut(){
        $this->session->sess_destroy();
        $this->index();
    }


}

?>
